package com.hzit.bj1804.dianordermanagementwutongservice.service;



import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.hzit.bj1804.dian.entity.Orderinfo;
import com.hzit.bj1804.dian.entity.Productinfo;
import com.hzit.bj1804.dian.vo.OrderdetailsOrderinfoProductinfo;
import com.hzit.bj1804.dian.vo.OrderinfoMemberpay;
import com.hzit.bj1804.dian.vo.PageRequest;
import com.hzit.bj1804.dianordermanagementwutongservice.dao.MemberpayDAO;
import com.hzit.bj1804.dianordermanagementwutongservice.dao.OrderinfoDAO;
import com.hzit.bj1804.dianordermanagementwutongservice.dao.ProductinfoDAO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;


import java.util.Date;
import java.util.List;


@Service
public class OrderManagementServiceImpl implements OrderManagementService {
    @Autowired
    private OrderinfoDAO orderinfoDAO;
    @Autowired
    private MemberpayDAO memberpayDAO;
    @Autowired
    private ProductinfoDAO productinfoDAO;

    @Override
    public PageInfo<OrderdetailsOrderinfoProductinfo> selectAlls(PageRequest pageRequest) {
       PageHelper.startPage(pageRequest.getPage(), pageRequest.getLimit());
        List<OrderdetailsOrderinfoProductinfo> alls = memberpayDAO.selectByAlls();
        return new PageInfo<OrderdetailsOrderinfoProductinfo>(alls);
    }

    @Override
    public PageInfo<OrderdetailsOrderinfoProductinfo> selectByIdAlls(PageRequest pageRequest, int id) {
        PageHelper.startPage(pageRequest.getPage(), pageRequest.getLimit());
        List<OrderdetailsOrderinfoProductinfo> orderdetailsOrderinfoProductinfos = memberpayDAO.selectByIdAlls(id);
        return new PageInfo<OrderdetailsOrderinfoProductinfo>(orderdetailsOrderinfoProductinfos);
    }

    @Override
    public PageInfo<Orderinfo> selectTimes(PageRequest pageRequest, Date ordertime) {
        PageHelper.startPage(pageRequest.getPage(), pageRequest.getLimit());
        List<Orderinfo> orderinfos = orderinfoDAO.selectBytime(ordertime);
        return new PageInfo<Orderinfo>(orderinfos);
    }


    @Override
    public List<OrderinfoMemberpay> selectCardholdername(String cardholdername) {
        return memberpayDAO.selectByName(cardholdername);
    }

    @Override
    public int updatestatues(Orderinfo orderinfo) {
        return orderinfoDAO.updateByPrimaryKeySelective(orderinfo);
    }

    @Override
    public Productinfo selectshangping(int productid) {
        return productinfoDAO.selectByPrimaryKey(productid);
    }

    @Override
    public List<Productinfo> selectAlls() {
        return productinfoDAO.selectByAll();
    }
}
